#pragma once

#ifndef _INC_namevalues_
#define _INC_namevalues_


#define NUM_NAMESVALUES_TO_ALLOCATE 1
#define NUM_DECIMAL_DIGITS_TO_DISPLAY 4
#define ID_INDEX 0
#define SENSOR_INDEX 1


enum DataType
{
	tString,
	tBoolean,
	tInteger,
	tFloat,
	tNull,
	tUnknown,
	tDate
};


struct NameValue
{
	char    Name[MAX_PATH];
	char    StringValue[MAX_PATH];
	union
	{
		BOOL   BooleanValue;
		int       IntegerValue;
		float     FloatValue;
		time_t    DateValue;
	};
	DataType  DType;
};


int		AddNameValue(NameValue item, int recordNo, int fieldIndex);
//CEJSONAPI_API void	InitNameValues();
//
//CEJSONAPI_API void	DeallocateNameValues();
//CEJSONAPI_API void	CheckArray();
//CEJSONAPI_API void	PrintArray();
//CEJSONAPI_API void	DisplayANameValuePair(int rec_no, int nv_no);
void	AddRecord(NameValue item, int index, int recordNo, int fieldIndex);


#ifndef __namevaluescpp__

extern int numNameValuePairsPerRecord;
//Get the 1D Index to NameValues for NameValue in Records based upon Record number R
// and Name Value index I within record

//1D Array of name value pairs
extern NameValue * NameValues;

extern int RecordNo;      //Counts number of records, ie when parsing is done = num of records.
extern int NameValueIndex; //Counts number of name value pairs in each record, ie when done
extern int TotalNumNameValues;
//is number of name value pairs in each record. (Assumed same for all records.)
extern int total_num_allocated;
#endif

#define REC_NO(R,I)   ( numNameValuePairsPerRecord * (R)  + (I) )

extern "C" CEJSONAPI_API void PrintArray();
extern "C" CEJSONAPI_API void CheckArray();

#endif _INC_namevalues_


